package com.sikaryofficial.system.api.factory;

import com.sikaryofficial.common.core.domain.R;
import com.sikaryofficial.system.api.RemoteWorkBenchService;
import com.sikaryofficial.system.api.model.goods.GoodsTasteResp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 工作台服务降级处理
 *
 * @author qinjinyuan
 */
@Component
public class RemoteWorkBenchFallbackFactory implements FallbackFactory<RemoteWorkBenchService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteWorkBenchFallbackFactory.class);

    @Override
    public RemoteWorkBenchService create(Throwable throwable) {
        log.error("工作台服务调用失败:{}", throwable.getMessage());
        return new RemoteWorkBenchService() {

            /**
             * 初始化渠道商用户信息
             *
             * @return 结果
             */
            @Override
            public R<Void> removeGoodsCache() {
                return R.fail("removeGoodsCache error:" + throwable.getMessage());
            }

            @Override
            public R<List<GoodsTasteResp>> listGoodsTaste(String brandNo, String keyWord, Integer size) {
                return R.fail("listGoodsTaste error:" + throwable.getMessage());
            }
        };
    }
}
